#!/usr/bin/env bash

if [[ $UID -eq 0 ]]; then
  echo "SparkleShare can not be run as root. Things would go utterly wrong."
  exit 1
fi

case $1 in
  open|--open)
    invite=`date -u +%N`
    open=`echo $2 | sed 's/sparkleshare:\/\/addProject\///'`
    curl --insecure --output ~/SparkleShare/.$invite.xml $open
    mono "@ABS_INSTALL_DIR@/SparkleShare.exe"
    ;;
    version|--version)
      echo @VERSION@
    ;;
    help|--help)
      echo "Usage:"
      echo "  sparkleshare [OPTION]"
      echo
      echo "Options:"
      echo "  --open sparkleshare://URL         Open invite file at URL"
      echo "  --status-icon=[appindicator|gtk]  Use a specific status icon implementation"
    ;;
  *)
    mono "@ABS_INSTALL_DIR@/SparkleShare.exe" $@
    ;;
esac
